#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#include <cstring>

using namespace std;

struct Node
{
    int id, d;
    Node( ) { }
    Node( int _id, int _d )
        : id( _id ), d( _d ) { }
};

bool operator < ( const Node &a, const Node &b )
{
    return a.d < b.d;
}

vector<int> li[ 200001 ];
int n, m, a[ 100001 ], b[ 200001 ], c[ 200001 ];
set<Node> s;
bool visit[ 200001 ];

int find( int x )
{
    int l = 0, r = n + m - 1, mid;
    while ( l < r )
    {
        mid = ( l + r ) / 2;
        if ( b[ mid ] < x )
            l = mid + 1;
        else
            r = mid;
    }
    return l;
}

void init( )
{
    int i, v;
    for ( i = 0; i < n; i++ )
    {
        scanf("%d", &a[ i ]);
        b[ i ] = a[ i ];
    }
    for ( i = 0; i < n + m; i++ ) li[ i ].clear( );
    for ( i = 0; i < m; i++ )
        b[ n + i ] = i + 1;
    sort( b, b + n + m );
    for ( i = 0; i < n; i++ )
        li[ find( a[ i ] ) ].push_back( i );
    s.clear( );
    memset( visit, 0, sizeof( visit ) );
    for ( i = 1; i <= m; i++ )
    {
        v = find( i );
        if ( li[ v ].size( ) > 0 )
        {
            visit[ v ] = 1;
            s.insert( Node( v, li[ v ][ 0 ] ) );
        }
        else
            s.insert( Node( v, 100000000 + i ) );
    }
    memset( c, 0, sizeof( c ) );
}

void work( )
{
    int i, v, ans = 0;
    Node p;
    set<Node>::iterator ii;
    for ( i = 0; i < n; i++ )
    {
        v = find( a[ i ] );
        if ( visit[ v ] )
        {
            ii = s.find( Node( v, i ) );
            s.erase( ii );
            c[ v ]++;
            if ( c[ v ] < li[ v ].size( ) )
                s.insert( Node( v, li[ v ][ c[ v ] ] ) );
            else
                s.insert( Node( v, 100000000 + i + m + 1 ) );
            continue;
        }
        ans++;
        c[ v ]++;
        if ( c[ v ] < li[ v ].size( ) )
        {
            visit[ v ] = 1;
            s.insert( Node( v, li[ v ][ c[ v ] ] ) );
            ii = s.end( );
            ii--;
            visit[ ii->id ] = 0;
            s.erase( ii );
        }
    }
    printf("%d\n", ans);
}

int main( )
{
    while ( scanf("%d%d", &n, &m) != EOF )
    {
        init( );
        work( );
    }
    return 0;
}
